const {
  defineConfig
} = require('@vue/cli-service')

const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const {
  ElementPlusResolver
} = require('unplugin-vue-components/resolvers')
const {
  VantResolver
} = require('@vant/auto-import-resolver');


module.exports = defineConfig({
  transpileDependencies: true,
  //添加插件:让插件生效
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver(), VantResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver(), VantResolver()],
      }),
    ],
  },
  devServer: {
    proxy: {
      //可以代理很多网址 可以分别转发给不同的后端服务器
      //key:代理的地址，可以随便写 value代表代理规则
      "/api": {
        target: 'http://localhost:9998',
        //'http://localhost:9999/api/select'
        //  通过/api才可以使用跨域 
        //但是请求多了一个api 所以要把路径重写
        pathRewrite: {
          '^/api': ''
        }, //路径重写
        changeOrigin: true
      },
      // "/api2:"
    }
  }
})